<h1>Reporte de Facturas Liquidadas</h1>
<table class="tabla">
    <tr>
        <th>No. de Factura</th>
        <th>Monto</th>
        <th>Pago</th>
        <th>Nota Credito</th>
        <th>Nota Cargo</th>
        <th>Total Descuentos</th>
        <th>Pagos + Descuentos</th>
        <th>Adeudo</th>
        <th></th>
    </tr>
    <?php
    include_once '../../models/Factura.php';
    include_once '../../models/Pago.php';

    $factura = new Factura(0,0,0,0);
    $pagos = new Pago();

    $arrFacturas = $factura->getLiquidadas();

    if (!$arrFacturas) {
        echo "<h1>No hay ninguna Factura con adeudo</h1>";
    } else {

        while ($tempFactura = mysql_fetch_array($arrFacturas)) {

            if ($tempFactura['idfactura'] == 0) {
                
            } else {

                $strFactura = '';

                $strFactura .= '<tr>';
                $strFactura .= "<input type='hidden' value='$tempFactura[idfactura]' id='idFactura' name='idFactura'>";
                $strFactura .= "<td>$tempFactura[numfactura]</td>";
                $tempFactura['monto'] = $tempFactura['monto'] * 1.16;
                $strFactura .= "<td>$ " . ($tempFactura['monto']) . "</td>";


                $cantiPagos = $pagos->getMontoPagos($tempFactura['idfactura']);

                $strFactura .= $cantiPagos == "" ? "<td> -- </td>" : "<td>$ $cantiPagos</td>";
                $strFactura .= "<td> -- </td>";
                $strFactura .= "<td> -- </td>";
                
                //$strFactura .= $tempFactura['notacredito'] == "0"  ? "<td> -- </td>" : "<td>$tempFactura[notacredito] / $$tempFactura[montocredito]</td>";
                //$strFactura .= $tempFactura['notacargo'] == "0" ? "<td> -- </td>" : "<td>$tempFactura[notacargo] / $$tempFactura[montocargo]</td>";

                //$totalDesc = $tempFactura['montocargo'] + $tempFactura['montocredito'];
                
                //$totalDesc = $tempFactura['montocargo'] + $tempFactura['montocredito'];
                
                $monto = $tempFactura['monto'];
                //$pagosDes = ($cantiPagos + $totalDesc);
                $adeudo = $monto - $tempFactura['cantidadpagada'];


                $strFactura .= "<td></td>";
                $strFactura .= "<td> -- </td>";
                
                //$strFactura .= "<td>$ $totalDesc</td>";
                //$strFactura .= ($cantiPagos + $totalDesc) == "" ? "<td> -- </td>" : "<td>$ " . ($cantiPagos + $totalDesc) . "</td>";
                
                $strFactura .= "<td>$ $adeudo</td>";
                $strFactura .= "<td><input type=\"button\" value=\"Ver Detalles\" onclick=\"obtenerDetallesFactura('$tempFactura[idfactura]', 'contenido');\"></td>";
                $strFactura .= '</tr>';

                echo $strFactura;
            }
        }
    }
    ?>  
</table>